package com.springcloud.controller;

import com.springcloud.common.Friend;
import com.springcloud.service.IService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: 顾志杰
 */
@RestController
@Slf4j
public class Controller {
    @Autowired
    private IService iService;

    @GetMapping("/sayHi")
    public String sayHi(){
        return iService.sayHi();
    }

    @PostMapping("/sayHi")
    public Friend sayHi2(){
        Friend friend  = Friend.builder().name("client").port("1111").build();

        return iService.sayHiPost(friend);
    }


    @GetMapping("/retry")
    public String retry(Integer timeout){
        return iService.retry(timeout);
    }
}
